#ifndef MATRIXCHILDREN_HPP
#define MATRIXCHILDREN_HPP

namespace TermStructure {
    //! Transpose of a Matrix
    template <template<typename T1,typename T2> class TMatrix, typename T, typename TSize = unsigned long>
    class MatrixTransposed
    {
    protected:
        //! The underlying matrix
        TMatrix<T,TSize> *_underlyingMatrix;
    public:
        //! defualt constructor
        MatrixTransposed()
        {
            _underlyingMatrix = 0;
        }
        //! initiate from a matrix
        MatrixTransposed(const TMatrix<T,TSize> &matrix)
        {
            _underlyingMatrix = &matrix;
        }
        //! Get the i,j element
        const T &operator()(const TSize &i, const TSize &j) const
        {
            return this->_underlyingMatrix->operator()(j,i);
        }
        //! Get the i,j element
        T &operator()(const TSize &i, const TSize &j)
        {
            return this->_underlyingMatrix->operator()(j,i);
        }
        //! Get the length
        TSize GetLength(int i)
        {
            if(i == 0) return this->_underlyingMatrix->Getlength(1);
            else if(i==1) return this->_underlyingMatrix->GetLength(0);
            return -1;
        }
    };
}

#endif
